<?php
namespace app\admin\controller;

use app\BaseController;
use think\exception\HttpResponseException;

/**
 * 后台登录基础类
 */
class AdminBase extends BaseController{
	
	public $adminUser = null;

	// 控制器初始化
    public function initialize(){
    	parent::initialize();
    	
    	//判断是否登录
    	if(empty($this->isLogin())){//如果没登录，就跳转到登录界面
    		//echo '未登录';
    		return $this->redirect(url("login/index"),302);
    		// redirect('login/index')->send();exit;
    	}
    }

	// 判断是否登录
	public function isLogin(){
		$this->adminUser = session(config('admin.session_admin'));
		//echo '<pre>';print_r($this->adminUser);exit;
		if(empty($this->adminUser)){
			return false;
		}
		return true;
	}

	public function redirect(...$args){
		// halt(...$args);
		throw new HttpResponseException(redirect(...$args));
	}
}